(function () {
    'use strict';

    angular.module('KingAdmin.pages.pdev.devgroup')
        .controller('DevgroupModalCtrl', DevgroupModalCtrl);

    /** @ngInject */
    function DevgroupModalCtrl($scope, $uibModal, $stateParams, $timeout, $state,$uibModalInstance, DevgroupService) {
        var data = DevgroupService.getTreeData();
        $scope.treeData = data.result;
        $scope.treeshow = true;

        console.log();

        $scope.readyCB = function() {
            console.log('ready called!');

            console.log($scope.treeInstance);

            console.log(angular.element('#myTreeId').jstree(true).get_selected());
            angular.element('#myTreeId').bind('select_node.jstree', function (event, data) {
                // $scope.selectNode(data.node);
                $scope.selectedNode = data.node;
            })
        };

        $scope.basicConfig = {
            core: {
                check_callback: true,
                worker: true
            },
            'types': {
                'default': {
                    'icon': false
                }
            },
            "checkbox": {
                "keep_selected_style": false
            },
            'plugins': ['types', "wholerow"],
            'version': 1
        };

        $scope.selectNode = function (node) {
            console.log(node);

        };

        $scope.ok = function () {
            $uibModalInstance.close($scope.selectedNode);

        };
        $scope.cancel = function () {
            $uibModalInstance.dismiss('cancel');

        };
    }

})();
